X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/63a61ee2be3a902c27cd000d41b1a3a0280be21a..d0950076b4ac797578bc4286a9f631196b4c00c7:/Super%20Polarity/SuperPolarity.cs?ds=inline
diff --git a/Super Polarity/SuperPolarity.cs b/Super Polarity/SuperPolarity.cs
index 40f1477..8125f8c 100644
--- a/Super Polarity/SuperPolarity.cs
+++ b/Super Polarity/SuperPolarity.cs
@@ -7,6 +7,8 @@ using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Media;
+using Microsoft.Xna.Framework.Audio;
using SuperPolarity;
#endregion
@@ -17,16 +19,35 @@ namespace SuperPolarity
///
public class SuperPolarity : Game
{
- GraphicsDeviceManager graphics;
+ public GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
- MainShip player;
+ public static int OutlierBounds;
+
+ public Player Player;
+
+ Screen EntryScreen;
+
+ protected Song TitleSong;
+ protected Song GameSong;
+ protected SoundEffect GameOverSound;
public SuperPolarity()
: base()
{
graphics = new GraphicsDeviceManager(this);
+ graphics.PreferMultiSampling = true;
+ graphics.PreferredBackBufferWidth = 1280;
+ graphics.PreferredBackBufferHeight = 720;
+ graphics.ToggleFullScreen();
+
Content.RootDirectory = "Content";
+ ActorFactory.SetGame(this);
+ ParticleEffectFactory.SetGame(this);
+ ActorManager.SetGame(this);
+ ScreenManager.SetGame(this);
+
+ EntryScreen = (Screen)new TitleScreen(this);
}
///
@@ -37,9 +58,20 @@ namespace SuperPolarity
///
protected override void Initialize()
{
- player = new MainShip();
-
base.Initialize();
+
+ InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
+ InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
+
+ EntryScreen.Initialize();
+
+ OutlierBounds = 100;
+ }
+
+ protected void HandleFullScreenToggle(float value)
+ {
+ graphics.ToggleFullScreen();
+ graphics.ApplyChanges();
}
///
@@ -48,12 +80,17 @@ namespace SuperPolarity
///
protected override void LoadContent()
{
+
+ MediaPlayer.IsRepeating = true;
+ GameSong = Content.Load("Sound\\polaritytheme.wav");
+ GameOverSound = Content.Load("Sound\\gameover");
+
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
- Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
+ ScreenManager.Push(EntryScreen);
- player.Initialize(Content.Load("Graphics\\player"), playerPosition);
+ Player = new Player(this);
}
///
@@ -75,7 +112,9 @@ namespace SuperPolarity
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
- // TODO: Add your update logic here
+ ScreenManager.Update(gameTime);
+
+ Player.Update();
base.Update(gameTime);
}
@@ -86,15 +125,31 @@ namespace SuperPolarity
/// Provides a snapshot of timing values.
protected override void Draw(GameTime gameTime)
{
- GraphicsDevice.Clear(Color.CornflowerBlue);
+ GraphicsDevice.Clear(Color.White);
spriteBatch.Begin();
- player.Draw(spriteBatch);
+ ScreenManager.Draw(spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}
+
+ public void PlaySong(string songName)
+ {
+ // temp stuff before media manager is in
+ if (songName == "game")
+ {
+ MediaPlayer.Play(GameSong);
+ }
+ }
+
+ public void GameOver()
+ {
+ MediaPlayer.Stop();
+ GameOverSound.Play();
+ ScreenManager.Pop();
+ }
}
}